﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace HslCommunication.Core
{
	/// <summary>
	/// 监控上传和下载文件的信息
	/// </summary>
	// Token: 0x02000116 RID: 278
	public class MqttFileMonitor
	{
		/// <summary>
		/// 实例化一个默认的对象
		/// </summary>
		// Token: 0x060017EF RID: 6127 RVA: 0x0007CB0A File Offset: 0x0007AD0A
		public MqttFileMonitor()
		{
			this.dicLock = new object();
			this.fileMonitors = new Dictionary<long, MqttFileMonitorItem>();
		}

		/// <summary>
		/// 增加一个文件监控的对象信息
		/// </summary>
		/// <param name="monitorItem">文件监控对象</param>
		// Token: 0x060017F0 RID: 6128 RVA: 0x0007CB2C File Offset: 0x0007AD2C
		public void Add(MqttFileMonitorItem monitorItem)
		{
			object obj = this.dicLock;
			lock (obj)
			{
				bool flag2 = this.fileMonitors.ContainsKey(monitorItem.UniqueId);
				if (flag2)
				{
					this.fileMonitors[monitorItem.UniqueId] = monitorItem;
				}
				else
				{
					this.fileMonitors.Add(monitorItem.UniqueId, monitorItem);
				}
			}
		}

		/// <summary>
		/// 根据唯一的ID信息，移除相关的文件监控对象
		/// </summary>
		/// <param name="uniqueId"></param>
		// Token: 0x060017F1 RID: 6129 RVA: 0x0007CBA8 File Offset: 0x0007ADA8
		public void Remove(long uniqueId)
		{
			object obj = this.dicLock;
			lock (obj)
			{
				bool flag2 = this.fileMonitors.ContainsKey(uniqueId);
				if (flag2)
				{
					this.fileMonitors.Remove(uniqueId);
				}
			}
		}

		/// <summary>
		/// 获取当前所有的监控文件数据的快照
		/// </summary>
		/// <returns>文件监控列表</returns>
		// Token: 0x060017F2 RID: 6130 RVA: 0x0007CC04 File Offset: 0x0007AE04
		public MqttFileMonitorItem[] GetMonitorItemsSnapShoot()
		{
			object obj = this.dicLock;
			MqttFileMonitorItem[] result;
			lock (obj)
			{
				result = Enumerable.ToArray<MqttFileMonitorItem>(this.fileMonitors.Values);
			}
			return result;
		}

		// Token: 0x0400054F RID: 1359
		private Dictionary<long, MqttFileMonitorItem> fileMonitors;

		// Token: 0x04000550 RID: 1360
		private object dicLock;
	}
}
